Skip to content

Tuple: check empty compact images strictly, as theta does - #813

Open
leerho wants to merge 1 commit into
mainfrom
tuple-strict-empty-check
Open

leerho wants to merge 1 commit into
mainfrom
tuple-strict-empty-check

Conversation

@leerho

@leerho leerho commented Nov 20, 2026

Copy link
Copy Markdown
Member

The CompactTupleSketch reader now checks the first 8 bytes of an empty serial version 3 image, as the theta reader does since #776. Before this change, any image with the empty flag set was accepted, whatever its other preamble bytes held.

An empty image must have:

  • PreLongs = 1, SerVer = 3, Family = TUPLE (9), SketchType = CompactTupleSketch (1), and a zero unused byte 4;
  • the read-only, empty and compact flags set, with reserved flag bits 0, 5, 6 and 7 clear.

Ignored, as in theta:

Every empty-image writer checked writes this form: Java from 3.1.0 on (when serial version 3 began), C++ from 3.0.0 on, and Go. Legacy images (serial versions 1 and 2) are not changed.

Tests: the new TupleEmptyImageTest accepts the Java, older Java, C++ and Go empty forms, ignores the seed hash under a custom seed, and accepts trailing bytes. It rejects PreLongs 2 or 3, a nonzero unused byte, a missing read-only or compact flag, and each reserved flag bit. The four rejection tests fail on main.

The array-of-doubles compact reader is not changed here.

🤖 Generated with Claude Code

An empty serial version 3 CompactTupleSketch image must now have PreLongs=1,
SerVer=3, Family=TUPLE, SketchType=CompactTupleSketch, a zero unused byte,
and the read-only, empty and compact flags set with the reserved bits clear.
The ordered flag and the seed hash are ignored, as in theta (#776), so every
image written by Java since 3.1.0, C++ and Go still reads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant